//
//  JMTeamTVController.m
//  jiMuOperate
//
//  Created by 胡梅方 on 16/4/29.
//  Copyright © 2016年 jinXinFengLi. All rights reserved.
//

#import "JMTeamTVController.h"
#import "JMTableVController.h"
#import "JMStagemenVController.h"
#import "JMMembersVController.h"
#import "JMGetTeamDataInfo.h"
#import "JMMyBindingTVController.h"
#import "JMTeamRankTController.h"

@interface JMTeamTVController ()

@end

@implementation JMTeamTVController

- (void)viewDidLoad {
    NSLog(@"xiugailezheli");
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView.scrollEnabled = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10)];
    self.tableView.tableHeaderView = view;
     HIDDENNAV(NO);
    self.tableView.backgroundColor = BACKCOLOR;
    self.navigationItem.title = @"团队";
   ;
 
    
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    HIDDENNAV(NO);

}
//
//-(void)requestGetTeamDataWithToken:(NSString*)token
//{
//    NSString *url = [NSString stringWithFormat:@"%@%@",JMURLGetTeamData,token];
//    NSArray *arrayR = @[@"",url,@"GET"];
//    [Request startRequestWithArray:arrayR FinishedBlock:^(NSData *data) {
//        NSDictionary *dict = [JMData dictAndTestData:data];
//        JMGetTeamDataInfo *teamData = [JMGetTeamDataInfo objectWithKeyValues:dict];
//        JMGetTeamDataReturn *teamDataReturn = [JMGetTeamDataReturn objectWithKeyValues:teamData.data];
//        self.CommuneNumber = teamDataReturn.CommuneNumber;
//        self.MyBindNumber = teamDataReturn.MyBindNumber;
//        self.PineConeParkRank = teamDataReturn.PineConeParkRank;
//        self.StrategyPeopleNum= teamDataReturn.StrategyPeopleNumber;
//        NSLog(@"self.stratey%@",self.StrategyPeopleNum);
// 
//        
//        
//    } FailBlock:^(NSString *string) {
//        SHOWALERT(@"服务器繁忙，请梢后重试");
//    }];
//}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 4;
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *teamCell = @"teamCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:teamCell];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:teamCell];
        
    }
        UserEntity *user = [UserEntity shardUserInfo];

    CGFloat imageH = 50;
    UIImageView *describImg = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, imageH/2, imageH/2)];
    describImg.frame = [ToolViewAndData MyAutoLayout:describImg];
    UILabel *descibLabel = [[UILabel alloc]initWithFrame:CGRectMake(imageH+10, 0, imageH*2, imageH)];
    descibLabel.frame = [ToolViewAndData MyAutoLayout:descibLabel];
    UIButton *cellBtn = [ARC createButtonWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, imageH) Target:self Sel:@selector(cellBtnClick:)];
    cellBtn.tag = indexPath.row + BtnTag;
    [cell.contentView addSubview:cellBtn];
    descibLabel.textColor = [UIColor blackColor];
    [cell.contentView addSubview:descibLabel];
    [cell.contentView addSubview:describImg];
    
    UILabel *smalTitleLabel = [[UILabel alloc]initWithFrame:CGRectMake(180, 0, 100, 50)];
    smalTitleLabel.frame = [ToolViewAndData MyAutoLayout:smalTitleLabel];
    smalTitleLabel.font = [UIFont systemFontOfSize:13];
    smalTitleLabel.textColor = [UIColor redColor];
    [cell.contentView addSubview:smalTitleLabel];
    UIImageView *lineImg = [[UIImageView alloc]initWithFrame:CGRectMake(0,50, 320, 1)];
    lineImg.image = [UIImage imageNamed:@"halvingline_2"];
    [cell.contentView addSubview:lineImg];
    lineImg.frame = [ToolViewAndData MyAutoLayout:lineImg];
    
    cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"aut_ico_arrow"]];
    switch (indexPath.row) {
        case 0:{
            describImg.image = [UIImage imageNamed:@"aut-_Strategy-member_ico"];
            descibLabel.text = @"社员";
            smalTitleLabel.text = [NSString stringWithFormat:@"团队成员%@人",user.CommuneNumber];
            break;
        }
        case 1:{
            describImg.image = [UIImage imageNamed:@"aut_ico_member"];
            descibLabel.text = @"策略员";

            smalTitleLabel.text = [NSString stringWithFormat:@"成员%@人",user.StrategyPeopleNum];
            
        
            break;
        }
        case 2:{
            describImg.image = [UIImage imageNamed:@"aut_binding_ico"];
            descibLabel.text = @"我绑定的";
            smalTitleLabel.text = [NSString stringWithFormat:@"%@个策略人",user.MyBindNumber];
            break;
        }
        case 3:{
            describImg.image = [UIImage imageNamed:@"aut_ranking_ico"];
            descibLabel.text = @"团队排行";

            smalTitleLabel.text = [NSString stringWithFormat:@"当前排位%@",user.PineConeParkRank];
             break;
        }
        default:
            break;
    }
    
    [cell.contentView addSubview:[ARC createImageViewLineWithHeigt:1]];
    return cell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return CELLHIGHT;
}

-(void)cellBtnClick:(UIButton*)btn
{
    switch (btn.tag-BtnTag) {
        case MembersBtn:{
            JMMembersVController *membersVc = [[JMMembersVController alloc]init];
            [self.navigationController pushViewController:membersVc animated:YES];
            break;
        }
        case StrategyBtn:{
            JMStagemenVController *stageVc = [[JMStagemenVController alloc]init];
            [self.navigationController pushViewController:stageVc animated:YES];
            break;
        }
        case MyBingingBtn:{
            JMMyBindingTVController *myBindingVC = [[JMMyBindingTVController alloc]init];
            [self.navigationController pushViewController:myBindingVC animated:YES];
            break;
        }
        case TeamRankingBtn:{
            JMTeamRankTController *teamRankVC = [[JMTeamRankTController alloc]init];
            [self.navigationController pushViewController:teamRankVC animated:YES];
            break;
        }
            
            
        default:
            break;
    }
}

@end
